<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  let arr = [1, 2, 3, 4, 5, 6]

  let numbers = arr.filter(i => i > 2);
  console.log(numbers)

  // 箭头函数的弊端
  //  递归函数，事件处理函数时不太适用箭头函数，命名函数也有用武之地，能用箭头函数，就要用箭头函数

  // 递归demo
  // 递归求阶乘
  function x(num) {
    if (num <= 1) return 1;
    return num * x(num - 1)
  }

  console.log(x(3))

  //   递归求和
  let d = [1, 2, 3, 4, 5]

  function s(...arr) {
    console.log(arr)
    if (arr.length === 0) return 0;
    return arr.pop() + s(...arr)
  }

  //  打印倒三角
  function star(num) {
    if (num == 0) return '';
    document.write('*'.repeat(num) + "<br/>")
    star(--num)
  }

  star(5)
</script>

</body>
</html>